package com.pachong.frameworkdemo.app;

import android.content.res.TypedArray;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.pachong.android.baseuicomponent.activity.BaseActivity;
import com.pachong.android.framework.picture.picker.utils.FileManager;
import com.pachong.android.frameworkbase.utils.SLog;
import com.pachong.android.frameworkbase.utils.io.FileUtil;
import com.pachong.android.frameworkbase.utils.zip.ZipExtractor;
import com.pachong.frameworkdemo.R;

public class MainActivity extends BaseActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        String url = "file:///android_asset/www/test_tel.html";

        MainBottomFragment menuFragment  = (MainBottomFragment) getSupportFragmentManager().findFragmentById(R.id.fragBottomMenu);
        hideToolbar();

     /*   TokenInfo info = new TokenInfo();
        info.setExpiresAt("");
        info.setAccessToken("AF318BE799982C97457092AEDA03CE4818724A13D80CF940E75D8AD2E24FB88ABD3165327F97AABB");
        info.setRefreshToken("AF318BE799982C97AECD790497EA6F4CD76F46F2ADECB9A9562CBD088F3E8D02E7A2A6D1E1419C0D");
        info.setServerTime("2016-07-21T14:43:41.080+0800");
        info.setMacKey("qjBDKRD6yJ");

        String url = "http://120.76.200.15:8888/uc/user";
        String authStr = Authorization.createAuthorization(info, url, "get");
        Log.e("vivi", "  auth string === " + authStr);*/

//        testGetAppAttrs();

        String path = FileManager.getWebCachePath(this) + "zygote_web_cache.zip";
        String toPath = FileManager.getWebCachePath(this) + "zygote_web_cache";
        FileUtil.copyAssetToSDCard(getAssets(), "www/zygote_web_cache.zip", path);


        ZipExtractor zipExtractor = new ZipExtractor(this,
                path, toPath,
                new ZipExtractor.OnExtractListener() {
                    @Override
                    public void onProgressUpdate(long currSize) {
                        SLog.e("onProgressUpdate currSize == " + currSize);
                    }
                    @Override
                    public void onComplete(long totalSize) {
                        SLog.e("onComplete totalSize == " + totalSize);
                    }

                    @Override
                    public void onFailure(int errorCode, long totalSize,
                                          long currSize) {
                        SLog.e("onFailure errorCode == " + errorCode + "totalSize" + totalSize);
                    }

                    @Override
                    public void onCaculateTotalSize(long totalSize) {
                        SLog.e("onCaculateTotalSize totalSize == " + totalSize);
                    }

                });
        zipExtractor.execute();


    }

    @Override
    public View createDataView(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) {
        return layoutInflater.inflate(R.layout.activity_main, null);
    }


    void testGetAppAttrs() {
//        TypedArray typedArray1 = obtainStyledAttributes(R.styleable.IconTextArrowButton);
        TypedArray typedArray1 = obtainStyledAttributes(null,R.styleable.BadgeRadioButton,R.attr.badgeRadioButtonStyle,0);
        float drawHeight = typedArray1.getDimension(R.styleable.BadgeRadioButton_drawableHeight, -1.0f);
        Log.e("vivi", "   textSize  ==  " + drawHeight);
        typedArray1.recycle();

        TypedArray typedArray = obtainStyledAttributes(R.styleable.vidroid);
        float textSize1 = typedArray.getDimension(R.styleable.vidroid_textSize1, -1.0f);
        Log.e("vivi", "   textSize1  ==  " + textSize1);
        typedArray.recycle();
    }


}
